#练习 39. 字典，可爱的字典
# things = ['a', 'b', 'c', 'd']
# print(things[1])
# things[1] = 'z'
# print(things[1])
#
#
# stuff = {'name': 'Zed', 'age': 39, 'height': 6 * 12 + 2}
# print(stuff['name'])
#
# print(stuff['age'])
#
# print(stuff['height'])
#
# stuff['city'] = "SF"
# print(stuff['city'])
#
#
# stuff[1] = "Wow"
# stuff[2] = "Neato"
# print(stuff[1])
#
# print(stuff[2])
# print(stuff)
#
# del stuff['city']
# del stuff[1]
# del stuff[2]
# print(stuff)
# create a mapping of state to abbreviation #创建从州到缩写的映射
"""states = {
    'Oregon': 'OR',
    'Florida': 'FL',
    'California': 'CA',
    'New York': 'NY',
    'Michigan': 'MI'
   }#州，对应简称

# create a basic set of states and some cities in them #创建一组基本的州和其中的一些城市
cities = {
    'CA': 'San Francisco',
    'MI': 'Detroit',
    'FL': 'Jacksonville'
 }

# add some more cities # add some more cities #增加更多的城市
cities['NY'] = 'New York'
cities['OR'] = 'Portland'

# print out some cities #打印出一些城市
print('-' * 10)
print("NY State has: ", cities['NY'])
print("OR State has: ", cities['OR'])

# print some states #打印一些州
print('-' * 10)
print("Michigan's abbreviation is: ", states['Michigan'])
print("Florida's abbreviation is: ", states['Florida'])

# do it by using the state then cities dict #用州和城市字典
print('-' * 10)
print("Michigan has: ", cities[states['Michigan']])
print("Florida has: ", cities[states['Florida']])

# print every state abbreviation #打印每个州的缩写
print('-' * 10)
for state, abbrev in list(states.items()):
    print(f"{state} is abbreviated {abbrev}")

# print every city in state #打印州内的每个城市
print('-' * 10)
for abbrev, city in list(cities.items()):
    print(f"{abbrev} has the city {city}")

# now do both at the same time #现在同时做这两件事
print('-' * 10)
for state, abbrev in list(states.items()):
    print(f"{state} state is abbreviated {abbrev}")
    print(f"and has city {cities[abbrev]}")

print('-' * 10)
# safely get a abbreviation by state that might not be there#安全地按州使用一个可能不存在的缩写
state = states.get('Texas')

if not state:
    print("Sorry, no Texas.")

# get a city with a default value #获取一个具有默认值的城市
city = cities.get('TX', 'Does Not Exist')
print(f"The city for the state 'TX' is: {city}")"""

"""给你所在的国家或其他国家建立城市和州/地区的类似映射。"""

province = {
    '湖南': '湘',
    '贵州': '贵',
    '广东': '粤',
    '湖北': '鄂',
    '山东': '鲁'
   }#省，对应简称

provincial_capital ={
    'CS': '长沙',
    'GY': '贵阳',
    'GZ': '广州',
    'WH': '武汉',
    'JN': '济南'
}#城市省会
#dd more city capitalsz增加更多城市省会
provincial_capital['海南'] = '海口'
provincial_capital['吉林'] = '长春'

# print out some cities #打印出一些城市
print('-' * 10)
print("CS State has: ", provincial_capital['CS'])
print("JN State has: ", provincial_capital['JN'])


#Print out some provincial abbreviations #打印一些省简称
print('-' * 10)
print("湖南 province is abbreviated as: ",province['湖南'])
print("湖北 province is abbreviated as: ", province['湖北'])


# print every state abbreviation #打印每个市的缩写
print('-' * 10)
for state, abbrev in list(provincial_capital.items()):
    print(f"{state} is abbreviated {abbrev}")